package com.ppc.config;

import com.ppc.properties.MinIoProperties;
import com.ppc.utils.MinIoUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置类用于创建minioUtil对象
 *
 * @author jianKangS1
 * @date 2023/12/20
 */
@Configuration
@Slf4j
public class MinIoConfiguration {


  /**
   * @param minioProperties
   * @return {@link MinIoUtil }
   * @description
   */
  @Bean //一开始就创建对象
  @ConditionalOnMissingBean //只要创建一个对象
  public MinIoUtil minioUtil(MinIoProperties minioProperties) {
    log.info("开始创建minio文件上传工具对象：{}", minioProperties);
    MinIoUtil minioUtil = new MinIoUtil();
    minioUtil.minIoProperties = minioProperties;
    minioUtil.init();
    return minioUtil;
  }
}